package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建一张表article
 * 表结构
 *  id 整数类型，主键，自增           唯一标识
 *  title 字符串类型，长度200个字符     文章标题
 *  content 字符串类型，长度1000个字符  文章正文
 */
public class Test {
    public static void main(String[] args) {

        try ( Connection conn =DBUtil.getConnection(); ){

            Statement statement = conn.createStatement();
            String sql="CREATE TABLE article ( " +
                    "id INT AUTO_INCREMENT PRIMARY KEY , " +
                    "title VARCHAR(200)  , " +
                    "content VARCHAR(1000) ) ";
            int num = statement.executeUpdate(sql);
            if (num>0){
                System.out.println("创建表成功");
            }else {
                System.out.println("创建表失败");
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
